<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const arr = [
            {
                id: 1,
                value: '正式'
            },
            {
                id: 2,
                value: '非正式'
            }
        ]


        const id = 1
        // console.log(arr.find(item => item.id === id)?.value || '未知');//了解一下

        const obj = arr.find(item => item.id === id)
        if (obj) {
            console.log(obj.value);
        } else {
            console.log('未知');
        }
    </script>
</body>

</html>